from sqlalchemy import String
from sqlalchemy.dialects.mysql import INTEGER, DATETIME, TEXT

from shop.model import db


class User(db.Model):
    __tablename__ = 'user'

    id = db.Column(INTEGER(11), primary_key=True)
    phone = db.Column(String(20))
    name = db.Column(String(32))
    create_time = db.Column(DATETIME)


def get_user_by_phone(phone):
    one_user = db.session.query(User).filter(User.phone == phone).first()
    return one_user
